import request from "@/utils/request";

enum API {
  // 获取全部菜单与按钮
  ALLMENU_URL = "/admin/acl/permission",
  // 添加菜单
  ADDMENU_URL = "/admin/acl/permission/save",
  // 修改菜单
  UPDATEMENU_URL = "/admin/acl/permission/update",
  // 删除菜单
  DELETEMENU_URL = "/admin/acl/permission/remove/",
}

// 获取菜单数据
export const reqAllMenu = () => request.get<any, any>(API.ALLMENU_URL);
// 新增或修改菜单
export const reqAddOrUpdateMenu = (data: any) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATEMENU_URL, data);
  } else {
    return request.post<any, any>(API.ADDMENU_URL, data);
  }
};
// 删除菜单
export const reqDeleteMenu = (menuId: number) =>
  request.delete<any, any>(API.DELETEMENU_URL + menuId);
